<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>网上购票</title>
<link rel="stylesheet" href="resources/css/frozen.css">
<link rel="stylesheet" href="resources/css/main.css">
<script src="resources/lib/zepto.min.js"></script>
<script src="resources/js/frozen.js"></script>
<script src="resources/js/config.js"></script>
<script src="resources/js/main.js"></script>

</head>
<body ontouchstart="">
	<header class="ui-header ui-header-positive ui-border-b">
		<i class="ui-icon-return" onclick="history.back()"></i>
		<h1>忘记密码</h1>
	</header>
	<footer class="ui-footer ui-footer-btn">
		<ul id="footer" class="ui-tiled ui-border-t">
			<li data-href="index.html" class="ui-border-r">
				<div>查询购票</div>
			</li>
			<li data-href="order.html" class="ui-border-r">
				<div>订单查询</div>
			</li>
			<li data-href="member.html">
				<div>会员中心</div>
			</li>
		</ul>
	</footer>
	<section class="ui-container">
		<section class="ui-selector">
			<div class="ui-form ui-border-t" style="margin: 20px 0 10px;">
				<form action="#">
					<div class="ui-form-item ui-form-item-show ui-border-b">
						<label for="mobile">手机号码</label>
						<input id="mobile" type="text" placeholder="请输入手机号码" value="">
					</div>
				</form>
			</div>
			<div class="ui-btn-wrap">
				<button id="btn-get-back" class="ui-btn-lg ui-btn-primary">
					找&nbsp;&nbsp;&nbsp;&nbsp;回
				</button>
			</div>
		</section>
	</section>

<script>
(function (){

	/* -------------------- 根据localStorage中的值，初始化界面 -------------------- */
	
	// 初始化起点站查询条件
	if(!!localStorage.mobile) {
		$("#mobile").val(localStorage.mobile);
	}
	
	// 保存按钮点击事件
	$("#btn-get-back").tap(function(){
		getBackPassword();
	});

	// 底部主菜单初始化
	initFooter("#footer");
})();

// 修改密码
function getBackPassword() {
	showLoading("#loading");
	
	var mobile = $.trim($("#mobile").val());
	
	if(!mobile) {
		showInfoTip("请填写手机号");
		return;
	}

	ajax({
		url: appConfig.baseUrl + "/Member.go",
		data: {
			method: "ResetPwd",
			mobile: mobile
		},
		failMessage: "找回密码失败，请重试",
		success: function(data) {
			hideLoading("#loading");
			
			if(data.success==true || data.success=="true") {
				sessionStorage.message = "新密码已经发送到您的手机";
				history.back();
			} else {
				showInfoTip("请检查短信，或五分钟后再试");
			}
		}
	});
}
</script>
</body>
</html>